package com.ruoyi.buss.report.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.buss.utils.ListUtil;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.buss.report.domain.ReportWgshLsb;
import com.ruoyi.buss.report.service.IReportWgshLsbService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 网格商户报表Controller
 * 
 * @author sxy
 * @date 2021-07-16
 */
@RestController
@RequestMapping("/reportLsb")
public class ReportWgshLsbController extends BaseController
{
    @Autowired
    private IReportWgshLsbService reportWgshLsbService;

    @Autowired
    private TokenService tokenService;
    /**
     *  网格商户业务进度表
     */
    @PreAuthorize(hasPermi = "buss:wgshlsb:list")
    @GetMapping("/wgshywjdb")
    public TableDataInfo list(ReportWgshLsb reportWgshLsb)
    {   reportWgshLsb.setSjrq(ListUtil.getSjrq(reportWgshLsb.getSjrq()));
        LoginUser userInfo = tokenService.getLoginUser();

        startPage();
        List<ReportWgshLsb> list = reportWgshLsbService.selectReportWgshLsbList(reportWgshLsb,userInfo,0);
        return getDataTable(list);
    }

    /**
     * 导出网格商户报表列表
     */
    @PreAuthorize(hasPermi = "buss:wgshlsb:exportWgshywjdbService")
    @Log(title = "网格商户业务进度表", businessType = BusinessType.EXPORT)
    @PostMapping("/exportWgshywjdbService")
    public void export(HttpServletResponse response, ReportWgshLsb reportWgshLsb) throws IOException
    { reportWgshLsb.setSjrq(ListUtil.getSjrq(reportWgshLsb.getSjrq()));
        LoginUser userInfo = tokenService.getLoginUser();

        List<ReportWgshLsb> list = reportWgshLsbService.selectReportWgshLsbList(reportWgshLsb,userInfo,0);
        ExcelUtil<ReportWgshLsb> util = new ExcelUtil<ReportWgshLsb>(ReportWgshLsb.class);
        util.exportExcel(response, list, "网格商户报表数据");
    }

    /**
     *  网格商户业务进度表
     */
    @PreAuthorize(hasPermi = "buss:wgshywjdbhz:list")
    @GetMapping("/wgshywjdbhz")
    public TableDataInfo wgshywjdbhz(ReportWgshLsb reportWgshLsb)
    { reportWgshLsb.setSjrq(ListUtil.getSjrq(reportWgshLsb.getSjrq()));
        LoginUser userInfo = tokenService.getLoginUser();

        startPage();
        List<ReportWgshLsb> list = reportWgshLsbService.selectReportWgshLsbList(reportWgshLsb,userInfo,1);
        return getDataTable(list);
    }

    /**
     *  网格商户业务进度表
     */
    @PreAuthorize(hasPermi = "buss:wgshywjdbMonth:list")
    @GetMapping("/wgshywjdbMonth")
    public TableDataInfo wgshywjdbMonth(ReportWgshLsb reportWgshLsb)
    {   reportWgshLsb.setSjrq(ListUtil.getSjrq(reportWgshLsb.getSjrq()));
        LoginUser userInfo = tokenService.getLoginUser();

        startPage();
        List<ReportWgshLsb> list = reportWgshLsbService.selectReportWgshLsbList(reportWgshLsb,userInfo,2);
        return getDataTable(list);
    }




}
